{% extends 'blog/base.html' %}
{% block title %}博客首页{% endblock %}
{% load blog_tags %}
{% block content %}
<div class="content-body">
    <div class="container">
        <div class="row">
            <main class="col-md-8">
                {% for post in posts %}
                    <article class="post post-{{ forloop.counter }}">
                        <header class="entry-header">
                            <h1 class="entry-title">
                                <a href="{{ post.get_absolute_url }}">{{ post.title }}</a>
                            </h1>
                            <div class="entry-meta">
                                <span class="post-category"><a href="#">博客类型</a></span>

                                <span class="post-date"><a href="#"><time class="entry-date" datetime="2012-11-09T23:15:57+00:00">{{ post.publish}}</time></a></span>

                                <span class="post-author"><a href="#">{{ post.author }}</a></span>

                                <span class="comments-link"><a href="">4 评论</a></span>

                                <span class="views-count"><a href="#">{{ post.views }} 阅读</a></span>
                            </div>
                        </header>
                        <div class="entry-content clearfix">
                            <p>{{ post.body|markdown|truncatewords:30|safe}}</p>
                            <div class="read-more cl-effect-14">
                                <a href="{{ post.get_absolute_url }}" class="more-link">继续阅读 <span class="meta-nav">→</span></a>
                            </div>
                        </div>
                    </article>
                {% endfor %}
                <div class="read-more ">
                    <nav aria-label="Page navigation">
                        <ul class="pagination">
                                {#上一页#}
                                 {% if posts.has_previous %}
                                    <li><a href="{{page_url}}?page={{ posts.previous_page_number }}">
                                        <span aria-hidden="true">&laquo;</span></a>
                                    </li>
                                 {% else %}
                                     <li class="disabled"><a href="javascript:void(0);">
                                         <span aria-hidden="false">&laquo;</span></a>
                                     </li>
                                 {% endif %}

                                {# 左边页码#}
                                {% if left_has_more %}
                                    <li><a href="{{page_url}}?page=1">1</a></li>
                                    <li><a href="javascript:void(0);">...</a></li>
                                {% endif %}
                                {% for left_page in left_pages %}
                                    <li><a href="{{page_url}}?page={{ left_page }}">{{ left_page }}</a></li>
                                {% endfor %}

                                {# 当前页#}
                                 <li class="active"><a href="{{page_url}}?page={{ current_page }}">{{ current_page }}</a></li>

                                {# 右边页码 #}
                                {% for right_page in right_pages %}
                                    <li><a href="{{page_url}}?page={{ right_page }}">{{ right_page }}</a></li>
                                {% endfor %}
                                {% if right_has_more %}
                                     <li><a href="javascript:void(0);">...</a></li>
                                    <li><a href="{{page_url}}?page={{ num_pages }}">{{ num_pages }}</a></li>
                                {% endif %}
                                {# 下一页 #}
                                {% if posts.has_next %}
                                    <li><a href="{{page_url}}?page={{ posts.next_page_number }}">
                                        <span aria-hidden="true">&raquo;</span></a>
                                    </li>
                                {% else %}
                                    <li class="disabled"><a href="javascript:void(0);">
                                         <span aria-hidden="false">&raquo;</span></a>
                                    </li>
                                {% endif %}
                        </ul>
                    </nav>
                </div>
            </main>
            <aside class="col-md-4">
                <div class="widget widget-recent-posts">
                    <h3 class="widget-title">最新文章</h3>
                    <ul>
                        {% show_latest_posts 4 %}
                    </ul>
                </div>
                <div class="widget widget-archives">
                    <h3 class="widget-title">归档</h3>
                    <ul>
                        {% pigeonhole_list_posts %}
                    </ul>
                </div>

                <div class="widget widget-category">
                    <h3 class="widget-title">分类</h3>
                    <ul>
                        {% for category in categorys %}
                        <li>
                            <a href="{% url 'blog:post_category' category.class_name %} ">{{ category.class_name }} <span class="post-count">({{ category.posts_category.count }})</span></a>
                        </li>
                        {% endfor %}
                    </ul>
                </div>

                <div class="widget widget-tag-cloud">
                    <h3 class="widget-title">标签云</h3>
                    <ul>
                        {% taggst_list %}
                    </ul>
                </div>
                <div class="rss">
                    <a href="{% url 'blog:post_feed' %}"><span class="ion-social-rss-outline"></span> RSS 订阅</a>
                </div>
            </aside>
        </div>
    </div>
</div>
{% endblock %}
